<template>
	<view>
		<view class="row ">
			<uni-pagination prevText="上一页" nextText="下一页" :total="pageInfo.totalCount"
				:pageSize="pageInfo.limit" :current="pageInfo.page" @change="pagination"></uni-pagination>
			<gt-select class="input-line input-sm page-limit ml-15" :list="pageLimitList" placeholder="10条"
				:value.Statussync="pageInfo.limit" @change="changePageLimit"></gt-select>
			<input class="input-line input-page ml-15 mr-15" type="number" v-model="searchPage" />
			<button class="btn btn-sm " @click="skipPage()"
				:disabled="searchPage == '' || searchPage ==  pageInfo.page || searchPage > pageInfo.totalPage">跳转</button>
		</view>
	</view>
</template>

<script>
	export default {
		name: "gt-table",
		props: {
			pageInfo: {
				type: [Array, Object],
				default: function() {
					return {};
				}
			}
		},
		created() {
		},
		data() {
			return {
				searchPage: '',
				pageLimitList: [{
						key: 20,
						val: '20条'
					},
					{
						key: 30,
						val: '30条'
					},
					{
						key: 50,
						val: '50条'
					},
					{
						key: 100,
						val: '100条'
					},
				],
			}
		},
		computed: {
		},
		methods: {
			changePageLimit(e) {
				this.table.pageInfo.limit = e || 10;
				this.table.pageInfo.page = 0;
				this.getData();
			},
			// 分页获取列表
			pagination(e) {
				this.table.pageInfo.page = e.current
				this.getData();
			},

			// 分页跳转
			skipPage() {
				this.table.pageInfo.page = parseInt(this.searchPage)
				this.getData();
				this.searchPage = ''
			},
		}
	}
</script>

<style>

	button {
		border: none;
	}

	.page--active {
		background-color: black;
	}

	.page-limit {
		width: 80px;
		height: 28px;
	}
</style>
